package tag;

import java.io.IOException;
import java.io.StringWriter;
import java.util.Date;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.SimpleTagSupport;

public class HelloAttrTag extends SimpleTagSupport {

	private String message;

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
	public void doTag(){
		
			try {
				if(message !=null){
				PageContext context = (PageContext)getJspContext();
				JspWriter out =getJspContext().getOut();
				out.println(message);
				}else{
					StringWriter sw = new StringWriter();
						getJspBody().invoke(sw);
						Date date = new Date();
						getJspContext().getOut().println(sw.toString()+"  "+date.toString());
				}
			}catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (JspException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
